package net.caixiaomi.info.adapter;

import android.text.TextUtils;
import android.widget.ImageView;

import com.bumptech.glide.Glide;

import net.caixiaomi.info.R;
import net.caixiaomi.info.base.quickadapter.BaseQuickAdapter;
import net.caixiaomi.info.base.quickadapter.BaseViewHolder;
import net.caixiaomi.info.model.HomePlayClassifyItem;

/**
 * 首页九宫格
 */

public class HomeGridAdapter extends BaseQuickAdapter<HomePlayClassifyItem, BaseViewHolder> {


    public HomeGridAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(BaseViewHolder helper, HomePlayClassifyItem item) {
        try {
            helper.setText(R.id.title, item.getLotteryName());
            helper.setText(R.id.des, item.getSubTitle());
            ImageView imageView = helper.getView(R.id.image);
            Glide.with(imageView.getContext()).load(item.getLotteryImg()).into(imageView);
//            if (!TextUtils.equals(item.getPlayClassifyLabelId(),"0")) {
//                int labelId = Integer.valueOf(item.getPlayClassifyLabelId());
//                int flagResId = R.mipmap.ic_popular_tip;
//                ImageView flag = helper.getView(R.id.flag);
//                if (labelId == 1) {
//                    flagResId = R.mipmap.ic_single_tip;
//                } else if (labelId == 2) {
//                    flagResId = R.mipmap.ic_lottery_tip;
//                } else if (labelId == 3) {
//                    flagResId = R.mipmap.ic_awards_tip;
//                } else if (labelId == 4) {
//                    flagResId = R.mipmap.ic_lottery_tip;
//                }
//                flag.setImageResource(flagResId);
//                helper.setGone(R.id.flag, true);
//            } else {
//                helper.setGone(R.id.flag, false);
//            }
            helper.setGone(R.id.flag, false);
            if(TextUtils.equals(item.getSubTitle(),"敬请期待")){
                helper.setTextColor(R.id.des,mContext.getResources().getColor(R.color.secondary_text));
            }else{
                helper.setTextColor(R.id.des,mContext.getResources().getColor(R.color.orange_primary));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
